package com.withoutwords.engine;

import java.io.Serializable;

import org.json.JSONException;
import org.json.JSONObject;

import com.withoutwords.engine.social.SocialNetwork;
import com.withoutwords.engine.social.SocialUser;

public class MyInfo implements Serializable,ConvertableJson {
	/**
	 * 
	 */
	private static final long serialVersionUID = -338437554183459808L;
	SocialUser socialUser;
	String userId;
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public SocialUser getSocialUser() {
		return socialUser;
	}
	public void setSocialUser(SocialUser socialUser) {
		this.socialUser = socialUser;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String _email) {
		email = _email;
	}
	String email;
	@Override
	public JSONObject toJSON() {
		JSONObject obj = new JSONObject();
		try {
			obj.put("userId", userId);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			obj.put("socialUser", socialUser.toJSON());
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			obj.put("email", email);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return obj;
	}
	@Override
	public boolean fromJSON(JSONObject obj) {
		try {
			userId = obj.getString("userId");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			//return false;
		}

		try
		{
			
			email = obj.getString("email");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			//return false;
		}

		try
		{
			socialUser = new SocialUser();
			socialUser.fromJSON(obj.getJSONObject("socialUser"));
			
			
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			//return false;
		}
		// TODO Auto-generated method stub
		return false;
	}
	

}
